package com.gg.hj.controller;

import com.gg.common.pojo.SysMenus;
import com.gg.common.pojo.SysUsers;
import com.gg.common.view.ParentMenuView;
import com.gg.hj.service.SysMenusService;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
public class SysMenusController {
    @Resource
    private SysMenusService menusService;

    @ResponseBody
    @RequestMapping("/queryMenus.action")
    //TODO 查询登入人具有的角色 角色具有的菜单
    public List<ParentMenuView> queryMenus() throws Exception {
        SysUsers user = (SysUsers) SecurityUtils.getSubject().getSession().getAttribute("user");
        return this.menusService.menusService(user.getId());
    };
    @ResponseBody
    @RequestMapping("/searchQueryMenuAll.action")
    //TODO 查询登入人具有的角色 角色具有的菜单
    public  Map<Integer,Map<String,List<SysMenus>>> searchQueryMenuAll() throws Exception {
        SysUsers user = (SysUsers) SecurityUtils.getSubject().getSession().getAttribute("user");
        return this.menusService.menuMap(user.getId());
    };
}
